/*
 * 百度在线网络技术（北京）有限公司拥有本软件版权2021并保留所有权利。
 * Copyright 2021, Baidu.com,Inc 2:Baidu Online Network Technology (Beijing) Co.,Ltd,
 * All rights reserved.
 */

package com.azdebugit.google.guava;
 
import java.util.Collection;
 
import com.google.common.collect.ArrayListMultimap;
import com.google.common.collect.Multimap;
import com.google.common.collect.ImmutableSet;
 
public class App  
{  
 
    public static void main(String[] argv) throws java.io.IOException  
    { 
        Multimap<String, String> myMultimap = ArrayListMultimap.create();
        myMultimap.put("Fruits", "Bannana");
        myMultimap.put("Fruits", "Apple");
        myMultimap.put("Fruits", "Pear");
        myMultimap.put("Fruits", "Pear");
        myMultimap.put("Fruits", "Bannana");
        myMultimap.put("Fruits", "Apple");
        myMultimap.put("Fruits", "Pear");
        myMultimap.put("Fruits", "Pear");       
        myMultimap.put("Vegetables", "Carrot");
 
        //取key
        Collection<String> mykeys =myMultimap.keys();
        //去重
        mykeys=ImmutableSet.copyOf(mykeys);
        mykeys.stream().forEach(System.out::println);
        for (String mykey :mykeys ) {
            Collection<String> myvalue = myMultimap.get(mykey);
            //去重
            myvalue.stream().forEach(System.out::println);
            myvalue=ImmutableSet.copyOf(myvalue);
            System.out.println(myvalue);
        }      
    }
}